<html>
<head>
<#assign basePath=request.contextPath>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>流程审批</title>
    <!-- Bootstrap Core CSS -->
    <link href="${pageContext.request.contextPath}/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/bootstrap/css/font-awesome.min.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/bootstrap/css/form.lzy.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/bootstrap/css/good.lzy.css" rel="stylesheet">
    <style>
        .form_datetime{ position: relative;}
        .form_datetime small{ position: absolute; top: 7px; left: 270px; white-space: nowrap;}
        .form-group{ float: left; width: 100%; margin-bottom: 0;}
        .control-label{ line-height: 40px;}
    </style>
</head>
<body>
<div id="page-wrapper">
    <div class="content-header">
        <h5>
            流程审批 &gt; <strong>查看</strong>
        </h5>
    </div>
    <div class="panel panel-lzy">
        <div class="panel-body">
            <h5 class="tips-lzy">操作提示</h5>
            <ul class="tips-list-lzy">
                <li><span>◆&nbsp;请仔细核对需要审批的信息。</span></li>
                <li><span>◆&nbsp;审核意见可为空，为空状态审核通过则显示为同意。</span></li>
            </ul>
        </div>
    </div>
    <div class="panel panel-f5">
        <div class="panel-body">
            <form id="myForm" class="form-horizontal" method="post">
                <input type="hidden" name="id" id="id" value="${entity.id!}">
                <input type="hidden" name="token" id="token" value="${token!}">
                <input type="hidden" name="status" id="status" value="1">
            <#if entity.status != 1 && entity.status != 2>
            <#--<c:if test="${entity.status != 1 && entity.status != 2}">-->
                <div class="form-group">
                    <span class="control-label col-sm-2 col-xs-4"><font color="red">*</font> 备注：</span>
                    <div class="col-sm-9 col-xs-8">
                        <textarea class="form-control" cols="100" rows="6" name="remark" id="remark" maxlength="100" value="" placeholder="最多可输入100个字"></textarea>
                    </div>
                </div>
            <#--</c:if>-->
            </#if>
                <div class="form-group">
                    <span class="control-label col-sm-2 col-xs-4"></span>
                    <div class="col-sm-9 col-xs-8">
                    <#if entity.status != 1 && entity.status != 2>
                    <#--<c:if test="${entity.status != 1 && entity.status != 2}">-->
                        <button type="button" class="btn btn-success" onclick="submitForm(1);"><i class="fa fa-check"></i> 同意</button>
                        <button type="button" class="btn btn-danger" onclick="submitForm(2);"><i class="fa fa-close"></i> 拒绝</button>
                    <#--</c:if>-->
                    </#if>
                        <button type="button" class="btn btn-info" onclick="closePage();"><i class="fa fa-close"></i> 返回</button>
                    </div>
                </div>
            </form>

        </div>
    </div>
    <div class="panel panel-f5">
        <div class="panel-body">
            <div class="form-group">
                <span class="control-label col-sm-2 col-xs-4">申请方：</span>
                <div class="col-sm-9 col-xs-8">
                    <span class="form-control detail-span">${entity.applicantName!}</span>
                </div>
            </div>
            <div class="form-group">
                <span class="control-label col-sm-2 col-xs-4">申请时间：</span>
                <div class="col-sm-9 col-xs-8">
                    <span class="form-control detail-span">${entity.submitTime!}</span>
             </div>
            <div class="form-group">
                <span class="control-label col-sm-2 col-xs-4">当前状态：</span>
                <div class="col-sm-9 col-xs-8">
                    <span class="form-control detail-span">
                        <#if entity.processStatus == 0>审核中</#if>
                        <#if entity.processStatus == 1>审核通过</#if>
                        <#if entity.processStatus == 2>审核失败</#if>
                        <#--<c:if test="${entity.processStatus == 0}">审核中</c:if>-->
                        <#--<c:if test="${entity.processStatus == 1}">审核通过</c:if>-->
                        <#--<c:if test="${entity.processStatus == 2}">审核失败</c:if>-->
                    </span>
                </div>
            </div>
            <div class="form-group">
                <span class="control-label col-sm-2 col-xs-4">审核事件：</span>
                <div class="col-sm-9 col-xs-8">
                    <span class="form-control detail-span">${entity.auditEventName!}</span>
                </div>
            </div>
            <div class="form-group">
                <span class="control-label col-sm-2 col-xs-4"><strong>审核流程：</strong></span>
                <div class="col-sm-9 col-xs-8">
                    <span class="form-control detail-span"><strong>${entity.processAssignee!}</strong></span>
                </div>
            </div>

            <div class="form-group">
                <span class="control-label col-sm-2 col-xs-4">审核记录</span>
                <div class="col-sm-9 col-xs-8">
                    <table class="table table-hover">
                        <thead>
                        <tr>
                            <th width="25%">时间</th>
                            <th width="25%">审核人</th>
                            <th width="25%">备注</th>
                            <th width="25%">审核意见</th>
                        </tr>
                        </thead>
                        <tbody id="tbodyId">
                        <#if taskList??>
                        <#--<c:if test="${null != taskList}">-->
                            <#list taskList as obj>
                            <#--<c:forEach items="${taskList}" var="obj">-->
                            <tr>
                                <td>${obj.endTime!}</td>
                                <td>${obj.assigneeName!}</td>
                                <td>${obj.remark!}</td>
                                <td>
                                    <#if obj.status == 1>同意</#if>
                                    <#if obj.status == 2>拒绝</#if>
                                <#--<c:if test="${obj.status == 1}">同意</c:if>-->
                                <#--<c:if test="${obj.status == 2}">拒绝</c:if>-->
                                </td>
                            </tr>
                            <#--</c:forEach>-->
                            </#list>
                        <#--</c:if>-->
                        </#if>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
    <div class="panel panel-f5">
        <div class="panel-heading">
        <#--<%--<h3 class="panel-title">● 业务数据 ${pageContext.request.contextPath}${entity.businessUrl}</h3>--%>-->
            <h3 class="panel-title">● 业务数据详情 ：</h3>
        </div>
        <div class="panel-body">
            <iframe id="viewDetail" name="viewDetail" style="background: aliceblue;" src="${pageContext.request.contextPath}${entity.businessUrl}" scrolling="auto" frameborder="0" width="100%" height="500px"></iframe>
        </div>
    </div>
</div>

<div class="good-add-suc">
    <span>
        <b>操作成功</b>
        该页面将在 5 秒后自动跳转！
        <a href="javascript:void(0)" onclick="closeAndRefreshPage();">返回列表</a>
    </span>
</div>

<#include "/WEB-INF/views/template/bootMainJs.ftl" parse=true encoding="utf-8">
<script src="${pageContext.request.contextPath}/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<!-- ajaxfileupload -->
<script	src="${pageContext.request.contextPath}/bootstrap/plugin/ajaxfileupload/ajaxfileupload.js" type="text/javascript"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/bootstrap/js/utils.js" type="text/javascript"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/bootstrap/plugin/jqPaginator/jqPaginator.js"></script>
<!-- bootstrap-datetimepicker -->
<script type="text/javascript" src="${pageContext.request.contextPath}/bootstrap/plugin/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/bootstrap/plugin/bootstrap-datetimepicker/bootstrap-datetimepicker.zh-CN.js"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/bootstrap-validator/0.5.3/js/bootstrapValidator.min.js"></script>
<script type="text/javascript">
    $(window).bootstrapValidator || document.write('<script src="${basePath}/bootstrap/js/bootstrapValidator.min.js"><\/script>');
</script>
<script>
    $(function(){

    });

    var action="${action}";
    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
    // 关闭窗口
    function closePage() {
        closeAndRefreshPage();
    }
    // 关闭窗口并刷新页面
    function closeAndRefreshPage() {
        parent.layer.closeAll();
        window.location.href = '${pageContext.request.contextPath}/admin/process/';
    }
    function submitForm(status) {
        var bsVal = $("#myForm").data('bootstrapValidator');
        bsVal.validate();
        if(bsVal.isValid()){
            $("#status").val(status);
            $.ajax({
                method : 'POST',
                dataType: 'json',
                url:  '${pageContext.request.contextPath}/admin/process/' + action,
                data: $("#myForm").serialize(),
                beforeSend:function(){
                    layer.load(2);
                },
                success: function (data) {
                    if (data.code == '0000' || data.code == '0') {
                        layer.open({
                            type: 1,
                            title: false,
                            content: $(".good-add-suc"),
                            area: ['600px', '300px'],
                            time: 5000,
                            end: function(){
                                closeAndRefreshPage();
                            }
                        });
                    } else {
                        layer.alert(data.desc, {
                            icon: 56
                        });
                    }
                },
                complete:function(){
                    layer.closeAll('loading');
                },
                error: function(){
                    layer.alert('系统错误', {
                        icon : 5
                    });
                }
            });
        }
        else{
            var smallTop = $("small:visible").eq(0).offset().top - 50;
            $("html,body").animate({scrollTop:smallTop},300);
        }
    }

    $("#viewDetail").load(function(){
        // 内嵌窗口加载完成事件
        $("div.content-header h5", window.frames["viewDetail"].document).addClass("hidden")
        $("div.form-group button.btn", window.frames["viewDetail"].document).addClass("hidden")
        $(".form-group:last", window.frames["viewDetail"].document).hide();
        $("hr", window.frames["viewDetail"].document).hide();
    });

    $('#myForm').bootstrapValidator({
        fields: {
            remark: {
                validators: {
                    notEmpty: {
                        message: '请输入备注'
                    }
                }
            }
        }
    });
</script>
</body>
</html>
